home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue72 / terminal / TerminalServices.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-06-03  |  3.2 KB  |  97 lines

  1. unit TerminalServices;
  2.  
  3. { conversions from WTSAPI32.H }
  4.  
  5. interface
  6.  
  7. Uses Windows;
  8.  
  9. {$MINENUMSIZE 4 - enumerations must be 32-bit values }
  10.  
  11. Const
  12.   WTS_CURRENT_SERVER_HANDLE = 0;
  13.   WTS_CURRENT_SESSION       = DWORD(-1);
  14.  
  15. Type
  16.   TConnectState = (    { WTS_CONNECTSTATE_CLASS }
  17.     WTSActive,         { User logged on to WinStation }
  18.     WTSConnected,      { WinStation connected to client }
  19.     WTSConnectQuery,   { In the process of connecting to client }
  20.     WTSShadow,         { Shadowing another WinStation }
  21.     WTSDisconnected,   { WinStation logged on without client }
  22.     WTSIdle,           { Waiting for client to connect }
  23.     WTSListen,         { WinStation is listening for connection }
  24.     WTSReset,          { WinStation is being reset }
  25.     WTSDown,           { WinStation is down due to error }
  26.     WTSInit);          { WinStation in initialization }
  27.  
  28.   PProcessInfo = ^TProcessInfo;
  29.   TProcessInfo = Record { WTS_PROCESS_INFOA }
  30.     SessionID   : Integer;
  31.     ProcessID   : Integer;
  32.     ProcessName : PChar;
  33.     UserSID     : PSID;
  34.   End;
  35.  
  36.   PProcessInfoArray = ^TProcessInfoArray;
  37.   TProcessInfoArray = Array[0..0] of TProcessInfo;
  38.  
  39.   PSessionInfo = ^TSessionInfo;
  40.   TSessionInfo = Record { WTS_SESSION_INFOA }
  41.     SessionID     : Integer;
  42.     WindowStation : PChar;
  43.     State         : TConnectState;
  44.   End;
  45.  
  46.   PSessionInfoArray = ^TSessionInfoArray;
  47.   TSessionInfoArray = Array[0..0] of TSessionInfo;
  48.  
  49.   TInfoClass = ( { WTS_INFO_CLASS }
  50.     WTSInitialProgram,
  51.     WTSApplicationName,
  52.     WTSWorkingDirectory,
  53.     WTSOEMId,
  54.     WTSSessionId,
  55.     WTSUserName,
  56.     WTSWinStationName,
  57.     WTSDomainName,
  58.     WTSConnectState,
  59.     WTSClientBuildNumber,
  60.     WTSClientName,
  61.     WTSClientDirectory,
  62.     WTSClientProductId,
  63.     WTSClientHardwareId,
  64.     WTSClientAddress,
  65.     WTSClientDisplay,
  66.     WTSClientProtocolType);
  67.  
  68. Function ProcessIdToSessionId(ProcessID : Integer; { from WINBASE.H }
  69.          Var SessionID : Integer) : Bool; StdCall;
  70.          External Kernel32 Name 'ProcessIdToSessionId';
  71.  
  72. Function WTSEnumerateProcesses(Server : THandle; Reserved,Version : Integer;
  73.          Var ProcessInfo : PProcessInfoArray; Var Count : Integer) : Bool; StdCall;
  74.          External 'WTSAPI32.DLL' Name 'WTSEnumerateProcessesA';
  75.  
  76. Function WTSEnumerateSessions(Server : THandle; Reserved,Version : Integer;
  77.          Var SessionInfo : PSessionInfoArray; Var Count : Integer) : Bool; StdCall;
  78.          External 'WTSAPI32.DLL' Name 'WTSEnumerateSessionsA';
  79.  
  80. Procedure WTSFreeMemory(Memory : Pointer); StdCall;
  81.           External 'WTSAPI32.DLL' Name 'WTSFreeMemory';
  82.  
  83. Function WTSQuerySessionInformation(Server : THandle; SessionID : LongWord;
  84.          Info : TInfoClass; Var Buf : Pointer;
  85.          Var BytesReturned : Integer) : Bool; StdCall;
  86.          External 'WTSAPI32.DLL' Name 'WTSQuerySessionInformationA';
  87.  
  88. Function WTSSendMessage(Server : THandle; SessionID : LongWord; Title : PChar;
  89.          TitleLength : Integer; AMessage : PCHar; MessageLength : Integer;
  90.          Style,TimeOut : Integer; Var Response : Integer;
  91.          Wait : Bool) : Bool; StdCall;
  92.          External 'WTSAPI32.DLL' Name 'WTSSendMessageA';
  93.  
  94. implementation
  95.  
  96. end.
  97.